//
//  def_function_definition.h
//  compilation
//
//  Created by Kevin Le perf on 17/01/12.
//  Copyright (c) 2012 e2co technologie. All rights reserved.
//

#ifndef compilation_def_functioertn_definition_h
#define compilation_def_functioertn_definition_h

/*
 function_definition
 : type_name declarator compound_statement {printf("function_defintion\n");
 enum type _type_name_here = type_name_stack_head();
 printf("valeur trouve "); type_print(_type_name_here);
 type_name_stack_pop();
 }
 ;

 */
struct def_function_definition{
	void * parent;
	int type;
	enum type type_name;
	struct def_declarator * declarator;
	struct def_compound_statement * compound_statement;
	
	char * name;
	struct symbol * signature;
};

struct def_function_definition * function_definition_create(void * parent){
	struct def_function_definition * f = malloc(sizeof(*f));
	f->parent = parent;
	f->type = 0;
	return f;
}

void function_definition_print(struct def_function_definition * f){
	switch(f->type){
		case 1:
			type_print(f->type_name);
			declarator_print(f->declarator);
			compound_statement_print(f->compound_statement);
			break;
		case 2:
			symbol_print(f->signature);
			compound_statement_print(f->compound_statement);
	}
}
#endif
